/* Tester.java */

import gameboard.*;
import player.*;
import player.MachinePlayer.ChipType;


public class Tester {
	
	public static void main(String[] args){
		
		GameBoard white = new GameBoard(1);
		GameBoard black = new GameBoard(0);
		
		/*System.out.println("Tests goals and corners for white");
		
		for(int x = 0; x < 8; x++){
			for(int y = 0; y < 8; y++){
				System.out.println("The tile at (" + x + ", " + y + ") is " + white.getValidity(x, y, ChipType.WHITE));
			}
		}
		
		System.out.println("\nTests goals and corners for black");
		for(int x = 0; x < 8; x++){
			for(int y = 0; y < 8; y++){
				System.out.println("The tile at (" + x + ", " + y + ") is " + black.getValidity(x, y, ChipType.BLACK));
			}
		}*/
		
		
		System.out.println("\nTHIS TESTS NEIGHBOURS BY EDITING A BOARD");
		white.changeChip(2, 2, ChipType.BLACK);
		white.changeChip(1, 4, ChipType.BLACK);
		white.changeChip(2, 4, ChipType.WHITE);
		white.changeChip(4, 3, ChipType.BLACK);
		white.changeChip(3, 3, ChipType.WHITE);
		GameBoardTile[] gbt = white.getNeighbours(3, 3); //getNeighbours should be changed to public when testing it.
		for(GameBoardTile ele: gbt){
			System.out.println("\nThe coordinate of this tile is " + ele.getX() + ", " + ele.getY());
			System.out.println("The chip at this tile is " + ele.getChip()); //change all these methods to public for testing.
			System.out.println("Black is valid in this tile? " + ele.getValidity(ChipType.BLACK));
			System.out.println("White is valid in this tile? " + ele.getValidity(ChipType.WHITE));
		}
		

		white.changeChip(4, 3, ChipType.EMPTY);
		white.changeChip(4, 5, ChipType.BLACK);
		white.changeChip(5, 4, ChipType.WHITE);
		gbt = white.getNeighbours(4, 4);
		System.out.println("\n\n");
		for(GameBoardTile ele: gbt){
			System.out.println("\nThe coordinate of this tile is " + ele.getX() + ", " + ele.getY());
			System.out.println("The chip at this tile is " + ele.getChip()); //change all these methods to public for testing.
			System.out.println("Black is valid in this tile? " + ele.getValidity(ChipType.BLACK));
			System.out.println("White is valid in this tile? " + ele.getValidity(ChipType.WHITE));
		}
		GameBoardTile elem = white.getTile(4, 4);
		System.out.println("\nThe coordinate of this tile is " + elem.getX() + ", " + elem.getY());
		System.out.println("The chip at this tile is " + elem.getChip()); //change all these methods to public for testing.
		System.out.println("Black is valid in this tile? " + elem.getValidity(ChipType.BLACK));
		System.out.println("White is valid in this tile? " + elem.getValidity(ChipType.WHITE));
		
		gbt = white.getNeighbours(0, 4);
		System.out.println("\n\n");
		for(GameBoardTile ele: gbt){
			System.out.println("\nThe coordinate of this tile is " + ele.getX() + ", " + ele.getY());
			System.out.println("The chip at this tile is " + ele.getChip()); //change all these methods to public for testing.
			System.out.println("Black is valid in this tile? " + ele.getValidity(ChipType.BLACK));
			System.out.println("White is valid in this tile? " + ele.getValidity(ChipType.WHITE));
		}
		
		
		MachinePlayer whitePlayer = new MachinePlayer(1);
		MachinePlayer blackPlayer = new MachinePlayer(0);

		/*System.out.println("\nTests valid moves if the machine player is white.");
		System.out.println("1. This should be false: " + whitePlayer.forceMove(new Move(0, 0)));
		System.out.println("2. This should be false: " + whitePlayer.opponentMove(new Move(0, 1)));		
		System.out.println("3. This should be false: " + whitePlayer.forceMove(new Move(1, 0)));
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(5, 3)));
		System.out.println("This should be false: " + whitePlayer.forceMove(new Move(5, 3)));
		System.out.println("6. This should be true: " + whitePlayer.opponentMove(new Move(1, 0)));
		System.out.println("This should be false: " + whitePlayer.forceMove(new Move(3, 8)));
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(5, 2)));		
		System.out.println("9. This should be false: " + whitePlayer.forceMove(new Move(4, 9)));
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(2, 6)));			
		System.out.println("This should be false: " + whitePlayer.forceMove(new Move(50, 0)));
		System.out.println("12. This should be false: " + whitePlayer.opponentMove(new Move(-123, 0)));	
		System.out.println("This should be true: " + whitePlayer.forceMove(new Move(0, 3)));
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(5, 7)));	
		
		System.out.println("\nTests valid moves if the machine player is black.");
		System.out.println("1. This should be false: " + blackPlayer.forceMove(new Move(0, 0)));
		System.out.println("2. This should be true: " + blackPlayer.opponentMove(new Move(0, 1)));		
		System.out.println("3. This should be true: " + blackPlayer.forceMove(new Move(1, 0)));
		System.out.println("This should be true: " + blackPlayer.opponentMove(new Move(5, 3)));
		System.out.println("This should be false: " + blackPlayer.forceMove(new Move(5, 3)));
		System.out.println("6. This should be false: " + blackPlayer.opponentMove(new Move(1, 0)));
		System.out.println("This should be false: " + blackPlayer.forceMove(new Move(3, 8)));
		System.out.println("This should be true: " + blackPlayer.opponentMove(new Move(5, 2)));		
		System.out.println("9. This should be false: " + blackPlayer.forceMove(new Move(4, 9)));
		System.out.println("This should be true: " + blackPlayer.opponentMove(new Move(2, 6)));			
		System.out.println("This should be false: " + blackPlayer.forceMove(new Move(50, 0)));
		System.out.println("12. This should be false: " + blackPlayer.opponentMove(new Move(-123, 0)));	
		System.out.println("This should be false: " + blackPlayer.forceMove(new Move(0, 3)));
		System.out.println("This should be false: " + blackPlayer.opponentMove(new Move(5, 7)));	
	*/
		System.out.println("\n1. This should be true: " + whitePlayer.forceMove(new Move(0, 3)));
		System.out.println("1. This should be true: " + whitePlayer.forceMove(new Move(1, 4)));
		System.out.println("1. This should be false: " + whitePlayer.forceMove(new Move(1, 3)));
		System.out.println("1. This should be false: " + whitePlayer.forceMove(new Move(2, 5)));
		System.out.println("1. This should be true: " + whitePlayer.forceMove(new Move(3, 3)));
		System.out.println("1. This should be true: " + whitePlayer.forceMove(new Move(4, 5)));
		System.out.println("1. This should be false: " + whitePlayer.forceMove(new Move(4, 4)));
		
		System.out.println("\nThis should be true: " + whitePlayer.opponentMove(new Move(3, 4)));	
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(5, 2)));	
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(5, 3)));	
		System.out.println("This should be true: " + whitePlayer.opponentMove(new Move(2, 4)));	
		System.out.println("This should be false: " + whitePlayer.opponentMove(new Move(1, 5)));
		System.out.println("This should be false: " + whitePlayer.opponentMove(new Move(5, 1)));	
		
		System.out.println("\n\n");
		for(Move move: whitePlayer.generateValidMoves(ChipType.WHITE)){
			System.out.println(move);
		}

			
	}
}
